package com.ly.share.juc.statistics;

/**
 * @author icanci
 * @since 1.0 Created in 2022/06/06 21:15
 */
public class LockDemo extends AbstractLockDemo {

    public static void main(String[] args) {
        LockDemo lockDemo = new LockDemo();
        Integer theSum = lockDemo.log(() -> {
            for (int i = 0; i < count; i++) {
                doSum();
            }
            return num;
        });
        System.out.println(theSum);
    }

    private static synchronized void doSum() {
        num++;
    }
}
